﻿<!DOCTYPE HTML>
<html lang="cn" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>

    <link href="/css/H-ui.min.css" rel="stylesheet" type="text/css"/>
    <link href="/css/H-ui.admin.css" rel="stylesheet" type="text/css"/>
    <link href="/lib/font-awesome/font-awesome.min.css" rel="stylesheet" type="text/css"/>
    <link href="/lib/iconfont/iconfont.css" rel="stylesheet" type="text/css"/>
    <link href="/command/bootstrap-4.4.1-dist/css/bootstrap.css" type="text/css" rel="stylesheet">
    <script type="text/javascript" src="/lib/jquery.min.js"></script>
    <script type="text/javascript" src="/command/bootstrap-4.4.1-dist/js/bootstrap.js"></script>
    <title>游戏管理</title>
</head>
<body>
<div class="cl pd-5 bg-1 bk-gray mt-20">
    <span class="l"><a href="javascript:;" onclick="deleteSelect()"
                       class="btn btn-danger radius"><i class="icon-trash"></i> 批量删除</a>
    <a href="javascript:;" onclick="user_add('550','','添加用户','/gameForm')" class="btn btn-primary radius"><i
            class="icon-plus"></i> 添加游戏</a>
<!--<a th:href="@{'/index'}"-->
<!--   class="btn btn-primary radius">-->
<!--    <i class="icon-plus"></i> 返回主页</a>-->
</span>
    <ul class="searchform text-right">
        <li>
            <form th:action="@{'/getGamesByName/1/'}">
                <input type="text" placeholder="根据游戏名查询"
                       name="titlename"
                       th:value="${titlename}"
                       style="border: 1px solid #E6E6E6;width:240px;">
                <input type="submit" value="搜索" class="btn btn-success">
            </form>
        </li>
    </ul>
</div>
<table class="table table-border table-bordered table-hover table-bg table-sort">
    <thead>
    <tr class="text-c">
        <th><input type="checkbox" name="" value=""></th>
        <th>ID</th>
        <th>游戏名</th>
        <th>游戏厂商</th>
        <th>游戏评分</th>
        <th>描述</th>
        <th>类别</th>
        <th>排名</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <tr th:each="game : ${gameList}" class="text-c" th:if="${count}!=0">
        <td><input type="checkbox" name="id[]" id="id[]" th:value="${game.id}"></td>
        <td th:text="${game.id}">1</td>
        <td th:text="${game.gname}">应用名</td>
        <td th:text="${game.author}">1</td>
        <td th:text="${game.score}">1</td>
        <td th:text="${game.description}">类型</td>
        <td th:text="${game.category}">40921</td>
        <td th:text="${game.grank}">11</td>
        <td class="f-14 game-manage"></a>
            <a title="编辑" href="javascript:;"

               style="text-decoration:none"
               th:href="@{'/modifyGame/'+${game.id}+'&'+${{titlename}}}">
                <i class="icon-edit"></i>
            </a>
            <a title="删除"
               href="javascript:;"

               class="ml-5"
               style="text-decoration:none"
               th:href="@{'/deleteGame/'+${game.id}+'&'+${pageNo}}"
            >
                <i class="icon-trash"></i></a>
        </td>
    </tr>

    </tbody>
</table>


<div class="container" th:if="${count}!=0">
    <ul class="pagination">
        <li class="page-item"><a class="page-link" th:href="@{'/gamelist/1'}" th:if="${pageNo}!=1">首页</a></li>
        <li class="page-item"><a class="page-link" aria-label="Previous" th:href="@{'/gamelist/'+${pageNo-1}}" th:if="${pageNo}!=1">&larr;上一页</a></li>


        <span th:each="page : ${#numbers.sequence(pageNo, currMaxPage)}" class="text-c">
                <span class="page-item active" th:if="${page}==${pageNo}"><a class="page-link" th:href="@{'/gamelist/'+${page}}" th:text="${page}"></a></span>
             <span class="page-item" th:if="${page}!=${pageNo}"><a class="page-link" th:href="@{'/gamelist/'+${page}}" th:text="${page}"></a></span>
        </span>

        <li class="page-item"><a  class="page-link" aria-label="Next" th:href="@{'/gamelist/'+${pageNo+1}}" th:if="${pageNo}!=${maxpage}">下一页&rarr;</a></li>
        <li class="page-item"><a class="page-link" th:href="@{'/gamelist/'+${maxpage}}" th:if="${pageNo}!=${maxpage}">尾页</a></li>
    </ul>
</div>
<div class="container">
        <span class="page-item page-link text-center" th:text="'共'+${count}+'条数据'"></span>
</div>

<script type="text/javascript" src="/lib/layer1.8/layer.min.js"></script>
<script type="text/javascript" src="/lib/laypage/laypage.js"></script>
<script type="text/javascript" src="/lib/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="/lib/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="/js/H-ui.js"></script>
<script type="text/javascript" src="/js/H-ui.admin.js"></script>
<script type="text/javascript" src="/js/H-ui.admin.doc.js"></script>


<script>
    var _hmt = _hmt || [];
    (function () {
        var hm = document.createElement("script");
        hm.src = "//hm.baidu.com/hm.js?080836300300be57b7f34f4b3e97d911";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
    })();
    var _bdhmProtocol = (("https:" === document.location.protocol) ? " https://" : " http://");
    document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F080836300300be57b7f34f4b3e97d911' type='text/javascript'%3E%3C/script%3E"));
</script>
<script>
    function app_del(obj, id) {
        layer.confirm('确认要删除吗？', function (index) {

            layer.msg('已删除!', 1);
        });
    }
</script>
<script th:inline="javascript">
    function deleteSelect(tablename) {
        let page=[[${pageNo}]];
        let Checkbox = false;
        $("input[name='id[]']").each(function() {
            if (this.checked === true) {
                Checkbox = true;
            }
        });
        if (Checkbox) {
            let t = confirm("您确认要删除选中的内容吗？");
            if (t === false) {
                return false;
            } else {
                let checkedID="";
                $("input[name='id[]']").each(function() {
                    if (this.checked == true) {
                        checkedID += this.value + ",";
                    }
                });
                window.location.replace("/delSelected/"+checkedID+"&"+page);
            }
        } else {
            alert("请选择您要删除的内容!");
            return false;
        }
    }
</script>
</body>
</html>